package com.briup.ch07;

/**
 * @Author briup-adam
 * @Date 2023/10/11 下午3:06
 * @Description
 **/

public class Stu {
    private String  name;
    private  int age;

    @Override
    public String toString() {
        return "Stu{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public Stu() {

    }

    public Stu(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj   instanceof  Stu){
            Stu s= (Stu) obj;
            return s.name.equals(this.name)? true:false;
        }else{
            return  false;
        }
    }
}
class  StuTest{
    public static void main(String[] args) {
        Stu stu1 = new Stu("小马", 18);
        Stu stu2 = new Stu("小马", 18);
        System.out.println(stu1==stu2);//false
        System.out.println(stu1.equals(stu2));//true
        System.out.println(stu1);
        System.out.println(stu2);
    }
}

